package com.mystudio.android.calendar.view;


import android.content.Context;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.mystudio.android.calendar.constants.Constants;
import com.mystudio.android.util.Logger;

public class MonthScrollView extends ScrollView {
	private static final Logger logger = new Logger(Constants.LOG_TAG, MonthScrollView.class);
	private LinearLayout monthListLayout;
	private int pageHeight;
	
	public MonthScrollView(Context context) {
		super(context);
		this.setFillViewport(true);
		
        monthListLayout = new LinearLayout(context);
        	monthListLayout.setOrientation(LinearLayout.VERTICAL);
        
        TextView textview2 = new TextView(context);
    		textview2.setText("April 2011");
    	monthListLayout.addView(textview2);

    	TextView textview1 = new TextView(context);
    		textview1.setText("March 2011");
    	monthListLayout.addView(textview1);
    	
        this.addView(monthListLayout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		logger.info("onMeasure: " + MeasureSpec.getSize(widthMeasureSpec) + ":" + MeasureSpec.getSize(heightMeasureSpec));
		for (int i=0; i<monthListLayout.getChildCount(); ++i) {
			monthListLayout.getChildAt(i).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, MeasureSpec.getSize(heightMeasureSpec)));
		}
		
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}
}
